{extend name="layout" /}
{block name="content"}
<div class="row">
  <div class="col-xs-6">
    <form id="searchForm">
      <div class="seardiv" style="width: 9%;float: left;">
        <select name="status" class="form-control input-sm">
          <option value="-1">全部</option>
          <option value="0">未使用</option>
          <option value="1">已使用</option>
          <option value="2">已失效</option>
        </select>
      </div>
      <div class="seardiv" style="width: 10%;float: left;">
        <select name="couponsid" class="form-control input-sm">
          <option value="">优惠券名</option>
          {volist name="couponsname" id="v"}
          <option value="{$key}">{$v}</option>
          {/volist}
        </select>
      </div>
      <div class="seardiv" style="width: 9%;float: left;">
        <select name="source" class="form-control input-sm">
          <option value="-1">来源</option>
          <option value="0">注册会员</option>
          <option value="1">单独补发</option>
          <option value="2">奖励</option>
        </select>
      </div>
      <div class="seardiv" style="width: 12%;float: left;">
        <select name="dealerid" class="form-control input-sm">
          <option value="">经销商</option>
          {volist name="deallist" id="v"}
          <option value="{$key}">{$v}</option>
          {/volist}
        </select>
      </div>
      <div class="seardiv" style="width: 10%;float: left;">
        <input class="form-control input-sm" placeholder="发券开始时间" type="text" name="startdate" id="startdate"
          AUTOCOMPLETE="off" value="">
      </div>
      <div class="seardiv" style="width: 10%;float: left;">
        <input class="form-control input-sm" placeholder="发券结束时间" type="text" name="enddate" id="enddate"
          AUTOCOMPLETE="off" value="">
      </div>
      <div class="seardiv" style="width: 10%;float: left;">
        <input class="form-control input-sm" placeholder="核销开始时间" type="text" name="checkstartdate" id="checkstartdate"
          AUTOCOMPLETE="off" value="">
      </div>
      <div class="seardiv" style="width: 10%;float: left;">
        <input class="form-control input-sm" placeholder="核销结束时间" type="text" name="checkenddate" id="checkenddate"
          AUTOCOMPLETE="off" value="">
      </div>
      <div class="input-group input-group-sm demoTable">
        <input type="text" class="form-control input-sm" name="keywords" id="demoReload" autocomplete="off"
          placeholder="请输入用户或优惠券编号">
        <span class="input-group-btn">
          <button type="button" class="btn btn-info btn-flat layui-btn" data-type="reload">搜 索</button>
        </span>
      </div>
    </form>
  </div>
  <div class="col-xs-6" style="text-align: right">
    <button type="button" class="btn btn-success btn-sm cocoModal" isForm url="{:url('add')}" title="新增项目" fixat="1"><i
        class="fa fa-plus"></i> 新增</button>
    <button type="button" class="btn btn-info btn-sm export" title="优惠券列表"><i class="fa fa-edit"></i> 数据导出</button>
  </div>
</div>
<table class="layui-table"
  lay-data="{height: 'full-75', cellMinWidth: 80, page: true, id:'lists',limit:30, url:'{:url('data_show_where',['order'=>'desc'])}'}"
  lay-filter="lists">
  <thead>
    <tr class="layui-colla-content">
      <th lay-data="{type:'checkbox'}">ID</th>
      <th lay-data="{field:'id', sort: true}">ID</th>
      <th lay-data="{field:'realname'}">用户</th>
	  <th lay-data="{field:'username'}">电话</th>
      <th lay-data="{field:'dealername'}">所属经销商</th>
      <th lay-data="{field:'sharename'}">分享用户</th>
      <th lay-data="{field:'typename'}">优惠券分类</th>
      <th lay-data="{field:'name'}">优惠券名称</th>
      <th lay-data="{field:'price2'}">线索金额</th>
      <th lay-data="{field:'couponsno'}">编号</th>
      <th lay-data="{field:'licenseno'}">车牌号</th>
      <th lay-data="{field:'carbrand'}">车型</th>
      <th lay-data="{field:'statusname'}">状态</th>
      <th lay-data="{field:'adminuser'}">核销人</th>
      <th lay-data="{field:'usedate'}">核销时间</th>
      <th lay-data="{field:'startdate'}">生效时间</th>
      <th lay-data="{field:'enddate'}">确认时间</th>
      {in name="$uinfo.roleid" value="1,4"}<th
        lay-data="{fixed: 'right', width:150, align:'center', toolbar: '#barDemo'}">操作</th>{/in}
  </thead>
</table>
<script type="text/html" id="barDemo">
  <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
</script>
{/block}
{block name="script"}
<script type="text/javascript">
  layui.use('table', function () {
    var table = layui.table;
    var $ = layui.$, active = {
      reload: function () {
        var demoReload = $('#demoReload');
        //执行重载
        table.reload('lists', {
          page: {
            curr: 1 //重新从第 1 页开始
          }
          , where: $('#searchForm').serializeObject()
        });
      }
    };
    $('.demoTable .layui-btn').on('click', function () {
      var type = $(this).data('type');
      active[type] ? active[type].call(this) : '';
    });
  });
  layui.use('laydate', function () {
    var laydate = layui.laydate;
    laydate.render({
      elem: '#startdate'
      , type: 'datetime'
      // ,value: "{:date('Y-m-d')}" + " 00:00:00"
    });
    laydate.render({
      elem: '#enddate'
      , type: 'datetime'
      // ,value: "{:date('Y-m-d H:i:s')}"
    });
    laydate.render({
      elem: '#checkstartdate'
      , type: 'datetime'
      // ,value: "{:date('Y-m-d H:i:s')}"
    });
    laydate.render({
      elem: '#checkenddate'
      , type: 'datetime'
      // ,value: "{:date('Y-m-d H:i:s')}"
    });
  });
</script>
{/block}